package rocketmq.demo.utils;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;

public class MqConfig {
	/**
	 * NameServer 地址
	 */
	public static final String DEFAULT_NAME_SRV_ADDR = "127.0.0.1:9876,127.0.0.1:9976";

	/**
	 * 
	 */
	public static final String GROUP_TEST = "testGroup";
	public static final String GROUP_TEST2 = "testGroup2";
	public static final String GROUP_ORDER = "orderGroup";
	public static final String GROUP_TEST4 = "testGroup4";
	public static final String GROUP_TEST5 = "testGroup5";

	public static final String TOPIC_SYNC = "TopicSync";
	public static final String TOPIC_ASYNC = "TopicAsync";
	public static final String TOPIC_ONE_WAY = "TopicOneWay";

	public static final String TOPIC_ORDER = "Topic_Order";
	public static final String TOPIC_BROADCAST = "Topic_Broadcast";
	public static final String TOPIC_SCHEDULE = "Topic_Schedule";
	public static final String TOPIC_FILTER = "Topic_Filter";
	public static final String TOPIC_LOGAPPENDER = "Topic_Logappender";
	public static final String TOPIC_OPENMESSAGING = "Topic_OpenMessaging";
	
	public static final String TOPIC_BATCH = "Topic_Batch";

	public static final String TAG_TEST = "testTag";

	public static byte[] writeKryoObject(Object object) {
		Output output = new Output(1024);
		Kryo kryo = new Kryo();
		kryo.writeObject(output, object);
		output.flush();
		output.close();
		byte[] ret = output.toBytes();
		output.clear();
		return ret;
	}

	public static <T> T readKryoObject(Class<T> tClass, byte[] bytes) {
		Kryo kryo = new Kryo();
		Input input = new Input(bytes);
		input.close();
		T ret = kryo.readObject(input, tClass);
		return ret;
	}

}
